<template>
	<view class="yhqPop">
		<view class="popTit spaceBet">
			<view>选择优惠券</view>
			<view class="useIntro hasFlex">
				<text class="intro" @tap="viewUseIntro">使用说明</text>
				<view class="iconfont icon-guanbi" @tap="closeSelYhq"></view>
			</view>
		</view>
		<view class="yhqType">
			<view class="typeItem" :class="[typeIndex == 0 ? 'active' : '']" @tap="selectType(0)">可用优惠券({{useLen}})<view class="liveView"></view></view>
			<view class="typeItem" :class="[typeIndex == 1 ? 'active' : '']" @tap="selectType(1)">不可用优惠券({{unLen}})<view class="liveView"></view></view>
		</view>
		<view class="popCon">
			<template v-if="yhqList != ''">
				<scroll-view class="scrollView" scroll-y >
					<!--  v-on="$listeners" -->
					<yhq-list :yhqList="yhqList" yhqType="useYhq" :typeIndex="typeIndex" :getCouponId="getCouponId" @goSelCurrYhq="goSelCurrYhq"></yhq-list>
				</scroll-view>
			</template>
			<template v-else>
				<no-data :marginTop="60" :marginBot="50"></no-data>
			</template>
		</view>
	</view>
</template>

<script>
	import YhqList from './YhqList.vue'
	export default {
		//inheritAttrs:false,
		props:{
			yhqList:Array,
			useLen:Number,
			unLen:Number,
			getCouponId:Number
		},
		components:{
			YhqList
		},
		data(){
			return{
				typeIndex:0
			}
		},
		methods:{
			selectType(index){
				this.typeIndex = index;
				this.$emit('selectYhqType',index);
			},
			viewUseIntro(){
				this.$emit('viewUseIntro');
			},
			closeSelYhq(){
				this.$emit('closeSelYhq');
			},
			//选择当前优惠券
			goSelCurrYhq(id,couponMoney){
				this.$emit('goSelCurrYhq',id,couponMoney);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.yhqPop{
		background: #F6F6F6;
		border-radius: 16rpx 16rpx 0 0;
		.popTit{
			height: 100rpx;
			line-height: 100rpx ;
			background: #FFF3DD;
			border-radius: 16rpx 16rpx 0 0;
			align-items: center;
			font-size: 32rpx;
			color: $pss-text-color3;
			padding: 0 0rpx 0 20rpx;
			font-weight: bold;
			.useIntro{
				color: $pss-text-color8;
				font-weight: normal;
				font-size: 28rpx;
				.intro{
					margin-right: 20rpx;
				}
				.icon-guanbi{
					width: 40rpx;
					height: 90rpx;
					font-size: 36rpx;
					padding: 0 15rpx;
				}
			}
		}
		.yhqType{
			height: 90rpx;
			background: #fff;
			display: flex;
			.typeItem{
				flex: 1;
				height: 90rpx;
				line-height: 90rpx;
				text-align: center;
				font-size: 30rpx;
				position: relative;
				.liveView{
					width: 14%;
					height: 6rpx;
					position: absolute;
					left: 43%; 
					bottom: 10rpx;
					border-radius: 20rpx;
					background:#F12918;
					display: none;
				}
				&.active{
					color: #F12918;
					.liveView{
						display: block;
					}
				}
			}
		}
		.popCon{
			padding: 20rpx;
		}
		.scrollView{
			height: 660rpx;
		}
	}
</style>